package com.pi.pro.xcmg.am.was.edi.mes.common;


import com.pi.common.utils.StringUtils;
import com.pi.framework.core.util.DateUtils;
import com.pi.pro.xcmg.am.common.vo.edi.KitDocumentLineReplyData;
import com.pi.pro.xcmg.am.common.vo.edi.KitDocumentReplyData;

import java.util.ArrayList;


public class MesWasExchangeSupport {


    public static KitDocumentReplyData ok(){
        KitDocumentReplyData replyData=new KitDocumentReplyData();
        replyData.setTimestamp(DateUtils.getCurrentDateAsString(DateUtils.FORMAT_DATE_YYYY_MM_DD_HH_MM_SS));
        replyData.setStatus(MesWasXcmgExchangeConstants.RESULT_STATUS_SUCCESS);
        replyData.setCode(MesWasXcmgExchangeConstants.RESULT_STATUS_CODE_SUCCESS);
        replyData.setErrMsg("成功");
        replyData.setInfo(new ArrayList<>());
        return replyData;
    }

    public static KitDocumentReplyData error(String errorText){
        KitDocumentReplyData replyData=new KitDocumentReplyData();
        replyData.setTimestamp(DateUtils.getCurrentDateAsString(DateUtils.FORMAT_DATE_YYYY_MM_DD_HH_MM_SS));
        replyData.setStatus(MesWasXcmgExchangeConstants.RESULT_STATUS_ERROR);
        replyData.setCode(MesWasXcmgExchangeConstants.RESULT_STATUS_CODE_ERROR);
        if (StringUtils.isNullOrBlank(errorText)){
            errorText="发生异常";
        }
        replyData.setErrMsg(errorText);
        replyData.setInfo(new ArrayList<>());
        return replyData;
    }

    public static String check(KitDocumentLineReplyData lineData){
        String m = "";
        if (lineData==null){
            m="配盘单数据为空.";
            return m;
        }
        if (StringUtils.isNullOrBlank(lineData.getPollNo())){
            m="配盘数据无效,配盘单号为空.";
            return m;
        }
        if (StringUtils.isNullOrBlank(lineData.getCompNo())){
            m="配盘数据无效,料号为空.";
            return m;
        }
        if (StringUtils.isNullOrBlank(lineData.getAskNum())){
            m="配盘数据无效,需求数量为空.";
            return m;
        }
        return m;
    }

}
